
<div class="breadcrumb d-flex align-items-center px-3">
    <div class="btn btn-icon me-3 js-back" aria-label="返回" role="button" tabindex="0">
        <i class="iconfont icon-left-arrow"></i>
    </div>
    <h2 class="fs-18"><?= $user->username ?></h2>
</div>

<?php include '_user_cover.php' ?>

<ul class="feed-list list-unstyled">
<?php if(!$favorites[0]): ?>
    <div class="placeholder fs-28">无</div>
<?php else: ?>
    <?php foreach ($favorites[0] as $fav): ?>
    <li class="feed-item d-flex js-tap" data-href="/post/show/<?= $fav->post_id ?>" data-pid="<?= $fav->post_id ?>">
        <a class="avatar" href="/user/profile/<?= $fav->author_id ?>" data-letters="<?= mb_substr($fav->username, 0, 1, 'UTF-8'); ?>"></a>
        <div class="d-flex flex-column w-100">
            <div class="d-flex align-items-center">
                <a class="link-dark fw-bold fs-15 post-meta" href="/user/profile/<?= $fav->author_id ?>"><?= $fav->username; ?></a>
                <a class="link-muted fs-15" href="/post/show/<?= $fav->post_id ?>"><?= nice_time($fav->created_at) ?></a>
                <div class="ms-auto dropdown">
                    <button class="btn btn-icon feed-item-action" type="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="iconfont icon-more fs-24"></i></button>
                    <div class="dropdown-menu dropdown-menu-end shadow-sm">
                        <a class="dropdown-item" href="#">
                            <i class="iconfont icon-shield me-2"></i>
                            <span class="fw-bold">取消收藏</span>
                        </a>
                    </div>
                </div>
            </div>
            <p class="typo-text"><?= $fav->content ?></p>
            <?php if($fav->images > 0): ?>
                <?php if($fav->type === 'gif'): ?>
                    <img class="feed-item-img align-self-baseline mt-2" data-gifffer="/upload/<?= $fav->filename ?>" alt="" loading="lazy" decoding="async">
                <?php else: ?>
                    <img class="feed-item-img align-self-baseline mt-2" src="/<?= thumb($fav->filename) ?>" alt="" data-zoomable loading="lazy" decoding="async">
                <?php endif ?>
            <?php endif ?>
        </div>
    </li>
    <?php endforeach; ?>
<?php endif ?>
</ul>

<?php if($favorites[1]->totalRows !== 0): ?>
<nav aria-label="Page navigation">
    <ul class="pagination justify-content-center p-3">
        <li class="page-item"><a class="page-link" href="<?= $favorites[1]->prevPage;?>"><span aria-hidden="true">&lsaquo;</span></a></li>
        <?php foreach($favorites[1]->listPage as $k=>$v): ?>
            <?php if($k == $favorites[1]->currentPage): ?>
                <li class="page-item"><a class="page-link active" href="<?= $v ?>"><?= $k ?></a></li>
            <?php else: ?>
                <li class="page-item"><a class="page-link" href="<?= $v ?>"><?= $k ?></a></li>
            <?php endif ?>
        <?php endforeach ?>
        <li class="page-item"><a class="page-link" href="<?= $favorites[1]->nextPage;?>"><span aria-hidden="true">&rsaquo;</span></a></li>
    </ul>
</nav>
<?php endif ?>

<script>
    document.addEventListener("DOMContentLoaded", (e) => {
        // 当前链接添加 active
        highlightActiveLink("user");
        document.getElementById("my-fav").classList.add('active');
    });
</script>